#ifndef NETWORK_H
#define NETWORK_H
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QNetworkAccessManager>
#include <QVariant>
#include <QDebug>
#include <QXmlStreamAttributes>
#include <QTextCodec>
#include <QtScript>
#include "datebase.h"
typedef struct
{
    QString carVehicle; //车号
    QString carRef; //返回状态
    QString carFlag; //车类型
    QString carAuto;  //提示音
    QString carFee;   //缴费
    QString carIntime;
    QString carOuttime;
    QString carParktime;
    QString carReason; //手动原因
    QString curTime;   ///空余车位
    QString pass_no;
    QString parked_time;
    QString update_time;
}carMessage;

/*class Producer : public QThread
{
     Q_OBJECT
public:
   void run();
   QString retu_Vehicle;
   QNetworkAccessManager *manager;
   QString cardown(QString Vehicle_id);
   bool Producer_WebCarMessage(QNetworkReply *reply);
   datebase *pt_mydb;
signals:
    void MsgSignal(QString);
};*/

class network
{
public:
    network(datebase *db);
    QNetworkAccessManager *webInforIn,*webInforOut,*webInforReason,*webInforHandIN,*webInforHandOUT,*webInforCar,*webInforInOutup,*webInforInOutdown;
    QNetworkAccessManager *webInforTime,*webInforRemain,*webFirstCar,*webTempPut,*webInforFree,*webInforTempIn,*webInforcarbind,*webInforcarstall;
private:
    datebase *mydb;
public slots:
    void carIn(QString Vehicle,QString);
    void carTempIn(QString Vehicle,QString image_name);
    void carOut(QString Vehicle,QString,QString vehicle_flag);
    void HandReason();
    void GetTime();
    void GetRemain();
    void FreeCar(ticketCheck_t *checkInfo,QString fact_fee);
    QString down_picture(QString date,QString picname);
    QString HandCroess(QString Vehicle,QString id);

    void FirstDownLoadCar();
    void DownLoadCar(QString);
    void tempcarimage(QByteArray,QString);
    bool uploadFile(QString localPath);


    bool generalWebHandOpen(QNetworkReply *reply,carMessage *carInfor);
    bool generalWebIn(QNetworkReply *reply,carMessage *carInfor);
    bool generalWebOut(QNetworkReply *reply,carMessage *carInfor);
    bool generalWebHand(QNetworkReply *reply);
    bool generalWebTime(QNetworkReply *reply,carMessage *carInfor);
    bool generalWebRemain(QNetworkReply *reply,carMessage *carInfor);
    bool generalWebCarMessage(QNetworkReply *reply,carMessage *carInfor);
    bool generalWebInOut(QNetworkReply *reply,carMessage *carInfor);
    bool generalWebCarFirst(QNetworkReply *reply);
    bool generalWebTempImage(QNetworkReply *reply,carMessage *carInfor);

    void WebPost_HandIn(QString OpenIn);
    void WebPost_HandOut(QString OpenOut);
    void WebPost_InOutRecord(QString record,QByteArray);
    void WebPost_InOutRecordupload(web_record_in_out info_record,QByteArray flag);
    void WebPost_InOutRecorddownload(QString max_updated_at);
    void WebPost_carbind_download(QString max_updated_at);
    void WebPost_car_stall_download(QString max_updated_at);
    bool generalWebInOutup(QNetworkReply *reply, web_record_in_out info_record);
    bool generalWebInOutdown(QNetworkReply *reply, QString lasttime);
    bool generalWebcarbinddown(QNetworkReply *reply);
    bool generalWebcarstalldown(QNetworkReply *reply);
};

#endif // NETWORK_H
